import cv2
import numpy as np
import face_recognition

imgMumu = face_recognition.load_image_file('Resources/mumu2.png')
imgMumu = cv2.cvtColor(imgMumu,cv2.COLOR_BGR2RGB)
imgTest = face_recognition.load_image_file('Resources/jiang.png')
imgTest = cv2.cvtColor(imgTest,cv2.COLOR_BGR2RGB)

# 图像中第一个人脸的位置
faceLoc = face_recognition.face_locations(imgMumu)[0]
encodeMumu = face_recognition.face_encodings(imgMumu)[0]
cv2.rectangle(imgMumu,(faceLoc[3],faceLoc[0]),(faceLoc[1],faceLoc[2]),(255,0,255),2)
# print(faceLoc)

# 图像中第一个人脸的位置
faceLoc2 = face_recognition.face_locations(imgTest)[0]
encodeMumuTest = face_recognition.face_encodings(imgTest)[0]
cv2.rectangle(imgTest,(faceLoc2[3],faceLoc2[0]),(faceLoc2[1],faceLoc2[2]),(255,0,255),2)

result = face_recognition.compare_faces([encodeMumu],encodeMumuTest)
print(result)

cv2.imshow('Mumu',imgMumu)
cv2.imshow("Mumu Test", imgTest)
cv2.waitKey(0)

